
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.log4j.Logger;

import com.aia.estore.general.Keys;
import com.tiptop.framework.exception.DBException;
import com.tiptop.orm.util.DBTransaction;


public class ILPDataSource implements DataSource {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(ILPDataSource.class);

	public Connection getConnection() throws SQLException {
		DBTransaction dbTrans = new DBTransaction();
		Connection estoreConn = null;
		try {
			estoreConn = dbTrans.getConnection(Keys.ESTOREDATASOURCE);
		} catch (DBException e) {
			System.err.println(e.getErrorMessage() + "::" + e.getErrorSQL());
			e.printStackTrace();
			logger.error("getConnection()", e); //$NON-NLS-1$
			throw new RuntimeException(e);
		}
		return estoreConn;
	}

	public Connection getConnection(String username, String password) throws SQLException {
		return getConnection();
	}

	public PrintWriter getLogWriter() throws SQLException {
		throw new RuntimeException("Not support this method");
	}

	public int getLoginTimeout() throws SQLException {
		throw new RuntimeException("Not support this method");
	}

	public void setLogWriter(PrintWriter out) throws SQLException {
		throw new RuntimeException("Not support this method");

	}

	public void setLoginTimeout(int seconds) throws SQLException {
		throw new RuntimeException("Not support this method");
	}
}
